// type
const ADD = 'add';
const DEL = 'del';
// storeage
const K = {
    jq: {
        num: 0
    },
    sc: {
        num: 0
    }
}
// opt jq table -- reducer
const JQ = (state = K, actions = {type: ADD, payload: 1}) => {
    let newData = {};
    
    switch(actions.type){
        case ADD:
            newData = {...state, jq: {num:state.jq.num + actions.payload}};break;
        case DEL:
            newData = {...state, jq: {num:state.jq.num - actions.payload}};break;
        default :
            newData = {...state}
    }

    return newData;
};
// doAdd
const doAdd = (num = 0) => {
    return {
        type: ADD,
        payload: num
    }
};
// doDel
const doDel = (num = 0) => {
    return {
        type: DEL,
        payload: num
    }
};
// async
const async = dispatch => (dispatch) => {
    setTimeout(()=>{
        dispatch(doAdd(2));
    },3000);
};
export { ADD, DEL, JQ, doAdd, doDel, async };